package cn.j0n4than.accountingtool.pojo;

import java.util.Date;

/**
 * 授权信息
 *
 * @author jonathan
 */
public class Auth {
    public static final String TYPE_ADMIN = "admin";
    public static final String TYPE_USER = "user";

    /**
     * 一秒
     */
    public static final long SEC = 1000;

    /**
     * 一分钟
     */
    public static final long MIN = 60 * SEC;

    /**
     * 一小时
     */
    public static final long HOUR = 60 * MIN;

    /**
     * 一天
     */
    public static final long DAY = 24 * HOUR;

    /**
     * 授权有效时间
     * 单位: 秒
     */
    public static final long EXPIRE_TIME = Auth.DAY;

    public int userId;
    public String ip;
    public Date expire = new Date(System.currentTimeMillis() + Auth.EXPIRE_TIME);
    public String type;

    @Override
    public String toString() {
        return "Auth{" +
                "userId=" + userId +
                ", ip='" + ip + '\'' +
                ", expire=" + expire +
                ", type='" + type + '\'' +
                '}';
    }
}
